using Cobra11Undercover.Material;
using Engine.Graphics;
using Engine.Graphics.Shaders;
using SharpDX.Direct3D11;
using System;

namespace Cobra11Undercover.Shaders.C11UndercoverShaders
{
    internal class Material112 : ShaderBaseC11Undercover, ISetShaderValues, ISetBlendStates, ISetSamplerStates
    {
        #region Private Fields

        private string name;

        #endregion Private Fields

        #region Public Constructors

        public Material112(Device renderDevice, string shaderDirectory, ShaderManager shaderManager)
            : base(renderDevice, shaderManager)
        {
            base.SetBlendStateObject(this);
            base.SetSamplerStateObject(this);
            string shaderName = "material17";
            this.name = shaderDirectory;
            base.LoadShader(renderDevice, shaderDirectory + "\\" + shaderName + ".fx", "ps_main", "vs_main");
            base.inputLayout = new InputLayout(renderDevice, base.shaderByteCodeVS, VertexStructures.C11UCVertexElements.elements);
            base.inputLayout.DebugName = "Input Layout " + shaderName;
        }

        #endregion Public Constructors

        #region Public Properties

        public ShaderBase Effect
        {
            get { return this.effect; }
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion Public Properties

        #region Public Methods

        public new void Dispose()
        {
            base.Dispose();
        }

        public new void SetBlendStates()
        {
            base.shaderManager.SetBlendState(StandardBlendStates.NoAlpha);
        }

        public void SetProperties(int materialID, MaterialManager materialManager)
        {
            C11Material material = (C11Material)materialManager.GetMaterialForGame(materialID);

            ShaderBase.SetTexture(0, materialManager.Textures[material.TextureID1], base.Device);
            ShaderBase.SetTexture(4, materialManager.Textures[material.TextureID3], base.Device);
        }

        public new void SetSamplerStates()
        {
            base.SetSamplerState(SamplerStateCollection.Standard, 0);
            base.SetSamplerState(SamplerStateCollection.Standard, 4);
        }

        #endregion Public Methods
    }
}